import { inject, injectable } from "inversify";
import { DiagnosticSeverity } from "vscode";
import { IDisposableRegistry, Resource } from "../../../common/types";
import { IServiceContainer } from "../../../ioc/types";
import { BaseDiagnostic, BaseDiagnosticsService } from "../base";
import { DiagnosticCommandPromptHandlerServiceId, MessageCommandPrompt } from "../promptHandler";
import { DiagnosticCodes, DiagnosticScope, IDiagnosticHandlerService } from "../types";

export const PowerShellActivationHackDiagnosticsServiceId =
    'EnvironmentActivationInPowerShellWithBatchFilesNotSupportedDiagnostic';
const PowershellActivationNotSupportedWithBatchFilesMessage =
    'Activation of the selected EQ environment is not supported in PowerShell. Consider changing your shell to Command Prompt.';


@injectable()
export class PowerShellActivationHackDiagnosticsService extends BaseDiagnosticsService {
    protected readonly messageService: IDiagnosticHandlerService<MessageCommandPrompt>;

    constructor(
        @inject(IServiceContainer) serviceContainer: IServiceContainer,
        @inject(IDisposableRegistry) disposableRegistry: IDisposableRegistry,
    ) {
        super(
            [DiagnosticCodes.EnvironmentActivationInPowerShellWithBatchFilesNotSupportedDiagnostic],
            serviceContainer,
            disposableRegistry,
            true,
        );
        this.messageService = serviceContainer.get<IDiagnosticHandlerService<MessageCommandPrompt>>(
            IDiagnosticHandlerService,
            DiagnosticCommandPromptHandlerServiceId,
        );
    }
}
export class PowershellActivationNotAvailableDiagnostic extends BaseDiagnostic {
    constructor(resource: Resource) {
        super(
            DiagnosticCodes.EnvironmentActivationInPowerShellWithBatchFilesNotSupportedDiagnostic,
            PowershellActivationNotSupportedWithBatchFilesMessage,
            DiagnosticSeverity.Warning,
            DiagnosticScope.Global,
            resource,
            'always',
        );
    }
}